#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT(tssp, 0.1, TakashiC.Ito@gmail.com)
AC_CONFIG_AUX_DIR([config])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/tssp.c])
AC_CONFIG_HEADERS([src/config.h])
AC_ARG_ENABLE([gcov], AC_HELP_STRING([--enable-gcov], [turn on code coverage analysis tools]))

# Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AM_CONDITIONAL(GCC, test "$GCC" = yes)   # let the Makefile know if we're gcc
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)
PKG_PROG_PKG_CONFIG

# Check for --enable-gcov and add appropriate flags for gcc
if test "x$enable_gcov" = "xyes"; then
    CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
fi

if test "$GCC" = yes ; then
    CFLAGS="$CFLAGS -Wall"
fi

# Checks for libraries.
AC_CHECK_LIB(event, evbuffer_add_printf)
AC_CHECK_LIB(dvbpsi, dvbpsi_NewDescriptor)

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([string.h])
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([inttypes.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([clock_gettime])

AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([pkgconfig/Makefile])
AC_CONFIG_FILES([test/Makefile])
AC_CONFIG_FILES([example/Makefile])
AC_CONFIG_FILES([pkgconfig/tssp.pc])

AC_OUTPUT

